﻿using HomagGroup.Base.UI.Windows;
using HomagGroup.BaseUI.Router;
using Proxy;
using System;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Media.Imaging;

namespace HomagChina.CCHCS
{
    public partial class App : Application
    {
        public App()
        {
        }

        protected override async void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            string imagePath = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "H330.png");
            BitmapImage imageSource = null;

            //await Task.Run(() =>
            // {
            //     // 在非 UI 线程上加载图像数据
            //     var bitmap = new BitmapImage();
            //     bitmap.BeginInit();
            //     bitmap.UriSource = new Uri(imagePath, UriKind.Absolute);
            //     bitmap.CacheOption = BitmapCacheOption.OnLoad;
            //     bitmap.EndInit();
            //     bitmap.Freeze();
            //     Application.Current.Dispatcher.Invoke(() =>
            //     {
            //         imageSource = bitmap;
            //     });
            // });

            SplashScreenWindow _SplashScreenWindow = new SplashScreenWindow();
            _SplashScreenWindow.OnStartup(imageSource, "HOMAG-China CCHS");
            new RouterModel();
            _SplashScreenWindow.Close();
            //new GantryTransport();
        }
    }
}